package nl.ru.rd.facedetection.nnbfd;

import nl.ru.rd.facedetection.nnbfd.neuralnetwork.BNLayer;
import nl.ru.rd.facedetection.nnbfd.neuralnetwork.Input;
import nl.ru.rd.facedetection.nnbfd.neuralnetwork.InputLayer;
import nl.ru.rd.facedetection.nnbfd.neuralnetwork.NeuralNetwork;
import nl.ru.rd.facedetection.nnbfd.neuralnetwork.SigmoidActivationfunction;

/**
 * A conventional Neural Network, with 400 inputs Neurons, 20 hidden Neurons and 1 Output Neuron.
 * 
 * Note: quite slow.
 * 
 * @author Wouter Geraedts (s0814857)
 */
public class ConventionalFacedetectionNetwork extends NeuralNetwork
{
	private static final long serialVersionUID = -276028048720516499L;

	public ConventionalFacedetectionNetwork()
	{
		super();
		this.initialize();
	}

	private void initialize()
	{
		Input[][] inputs = new Input[20][20];
		InputLayer inputLayer = new InputLayer();

		for(int i = 0; i < inputs.length; i++)
			for(int j = 0; j < inputs[i].length; j++)
			{
				inputs[i][j] = new Input(0.0);
				inputLayer.addInput(inputs[i][j]);
				this.registerInput(inputs[i][j]);
			}

		this.registerLayer(inputLayer);

		final SigmoidActivationfunction f = new SigmoidActivationfunction();

		BNLayer hiddenLayer1 = new BNLayer(inputLayer, 400, f);
		this.registerLayer(hiddenLayer1);

		BNLayer hiddenLayer = new BNLayer(hiddenLayer1, 20, f);
		this.registerLayer(hiddenLayer);

		BNLayer outputLayer = new BNLayer(hiddenLayer, 1, f);
		this.registerLayer(outputLayer);
		this.registerOutputLayer(outputLayer);
	}
}
